package arithmetic;

import java.util.ArrayList;
import org.junit.jupiter.api.Test;

/**
 * @author jiangfeng 2019/7/16 13:58
 * 演示栈溢出 和堆移除
 */
public class JavaStackOver {

    @Test
    public void testKillComputer(){
        while (true){
            new Thread(()->{
                while (true);
            }).start();
        }
    }

    /**
     * StackOverflowError
     */
    @Test
    public void reCall(){
        reCall();
    }

    /**
     *VM Args： -Xms20m -Xmx20m
     */
    @Test
    public void testHeadDump(){
        ArrayList<Object> objects = new ArrayList<>(10000);
        while (true){
            objects.add(new Object());
        }
    }

}
